from os.path import dirname

from vcs.models import Repository


def repo(backend, name, **kwargs):
    url = 'file://%(base)s/../fixtures/repositories/%(backend)s/%(name)s' % {
        'base': dirname(__file__),
        'backend': backend,
        'name': name
    }
    return Repository.objects.create(
        name=name,
        url=url,
        repository_type=backend,
        **kwargs
    )
